import request from '@/utils/request'

/**
 * 用户登录
 * post
 * @param {*} data
 */
export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    params: {
      username: data.username,
      password: data.password
    }
  })
}

// 用户注册
export function registration(data) {
  return request({
    url: '/user/registration',
    method: 'post',
    params: data
  })
}

// 用户忘记密码,获取密码
export function backPasswd(data) {
  return request({
    url: '/user/backPasswd',
    method: 'post',
    params: data,
    timeout: 50000
  })
}

// 通过用户token 获得用户的描述
export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

// 用户注销
export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

export function fetchUser(data) {
  return request({
    url: '/user/list',
    method: 'get',
    params: data
  })
}

export function searchUser(name) {
  return request({
    url: '/user/find',
    method: 'get',
    params: { name }
  })
}

export function transactionList(query) {
  return request({
    url: '/transaction/list',
    method: 'get',
    params: query
  })
}
